/*
 * @Author: fu.lanyun
 * @Date: 2019-01-25 13:59:54
 * @Desc: 静态的结构数据
 */

const baseTimeoutSetting = {
  "timeoutSetting": {					// 超时设置
    "isTimeout": "false",			// 是否超时设置
    "calendarType": "CALENDAR_DAY",  // 可以选择CALENDAR_DAY/日历日，WORKING_DAY/工作日
    // 时间间隔
    "day": 0,
    "hour": 0,
    "minute": 0,
    "timeoutNotifier": {			// 设置超时通知人
      "notifier": [// 通知人
        /*
        {
          "code": "15521152565",
          "name": "超级管理员"
          "type": "STA", // STA从组织库中选择, VAR流程变量中选择, INIT发起人
        }
        */
      ],
      "channel": [				// 通知渠道
        /*
        {
          "code": "SYSTEM",
          "name": "系统通知"
        }
        */
      ],
    },
    "warningSetting": {					// 预警设置
      "isWarning": "false",			// 是否预警设置
      "calendarType": "CALENDAR_DAY",  // 可以选择CALENDAR_DAY/日历日，WORKING_DAY/工作日
      "warningRegular": [// 预警规则
        /*
        {
          "warningCode": "task01",	// 预警编码
          "day": 0,
          "hour": 0,
          "minute": 0,
          "warningNotifier": {		// 设置预警通知人
            "notifier": [{			// 通知人
              "code": "15521152565",
              "name": "超级管理员",
              "type": "STA", // STA从组织库中选择, VAR流程变量中选择, INIT发起人
            }],
            "channel": [{			// 通知渠道
              "code": "SYSTEM",
              "name": "系统通知"
            }]
          }
        }
        */
      ],
    },
  },
};

/* 开始事件 */
const StartNoneEvent = {
  "resourceId": "",
  "properties": {
    "overrideid": "start",
    "name": "开始",
    "documentation": "",
    "executionlisteners": "",
    "initiator": "",
    "formkeydefinition": "",
    "formreference": "",
    "formproperties": {},
  },
  "stencil": {
    "id": "StartNoneEvent",
  },
};

/* 子流程开始节点 */
const GroupTaskStart = {
  "resourceId": "",
  "properties": {
    "overrideid": "groupstart",
    "name": "子流程开始",
    "documentation": "",
    "executionlisteners": "",
    "initiator": "",
    "formkeydefinition": "",
    "formreference": "",
    "formproperties": {},
  },
  "stencil": {
    "id": "GroupTaskStart",
  },
};


/* 结束事件 */
const EndNoneEvent = {
  "resourceId": "",
  "properties": {
    "overrideid": "end",
    "name": "",
    "documentation": "",
    "executionlisteners": "",
  },
  "stencil": {
    "id": "EndNoneEvent",
  },
}

/* 子流程结束节点 */
const GroupTaskEnd = {
  "resourceId": "",
  "properties": {
    "overrideid": "groupend",
    "name": "子流程结束",
    "documentation": "",
    "executionlisteners": "",
  },
  "stencil": {
    "id": "GroupTaskEnd",
  },
}

/* 子流程 shape:Subprocess */
const GroupTask = {
  "resourceId": "",
  "properties": {
    "overrideid": "",
    "name": "子流程",
    "documentation": "",
    "executionlisteners": "",
  },
  "stencil": {
    "id": "GroupTask",
  },
}

/* 子流程 shape:Subprocess */
const Subprocess = {
  "resourceId": "",
  "properties": {
    "overrideid": "subprocess",
    "name": "子流程",
    "documentation": "",
    "executionlisteners": "",
  },
  "stencil": {
    "id": "Subprocess",
  },
}

/* 用户任务 */
const UserTask = {
  "resourceId": "",
  "properties": {
    "overrideid": "", // 元素编码
    "name": "",
    "documentation": "",
    "asynchronousdefinition": "false",
    "exclusivedefinition": "false",
    "executionlisteners": "",
    "multiinstance_type": "None", // 会签 None：表示无会签，Parallel：表示并行会签，Sequential：表示串行
    "multiinstance_cardinality": "",
    "multiinstance_collection": "",
    "multiinstance_variable": "",
    "multiinstance_condition": "",
    "isforcompensation": "false",
    "mustExpress": '0',
    "forcePick": '0',
    "usertaskassignment": "", // 处理人
    "candidateGroups": [], // 用户组
    "candidateUsers": [], // 候选人
    "noticeChannel": [], // 办理人设置->通知渠道, 和candidateUsers一一对应 { code: '', name: '' }
    "relativeRelations": [], // 办理人设置->相对关系
    "copyTo": null, // 抄送人设置, null || [{ code: string, name: string, type: 'STA" } & {userCode: string, userName: string, userOrgDesc: string}]
    "description": "",
    "formId": "",
    "formkeydefinition": "",
    "formname": "",
    "formreference": "",
    "duedatedefinition": "",
    "prioritydefinition": "",
    "formproperties": "",
    "tasklisteners": "",
    "skipexpression": "",
    "categorydefinition": "NORMAL",
    "duedate": { // 已废弃
      "relativeTime": "None", // None ：未选择 ，calendar:相对于日历时间，work:相对于工作日时间
      "day": 0,
      "hour": 0,
      "minute": 0,
      "second": 0,
      "noticeusers": [],
      "noticetype": "notice",
    },
    ...baseTimeoutSetting,
    "httpcallback": {
      "isEmpty": true,  // 表示未勾选
      "parameters": [], // shape of { key: '', value:'' },
      "url": null,
    },
    "nodeAuth": {
      // "urge": {
      //   "switch": false,
      //   "urgeStartTime": "quarterHour",
      //   "urgeInterval": "oneMinute",
      // },
      "cancel": false,
      "signIn": true,
      "addSignature": false,
      "delegate": false,
      "transfer": false,
      // "circulation": false,
      // "delay": false,
      // "stop": false,
      // "rollback": false,
      "rollbackToPre": false,
      "rollbackToFirst": false,
      "rollbackToAny": false,
      "takeBack": false,
      "reissue": false,
      "nextNodeHandler": false,
      "readHandle": false,
      // "reject": false,
      "veto": false,
    },
    // "nodeVariables": [], // 不用设置节点的变量
  },
  "stencil": {
    "id": "UserTask",
  },
}

/* 脚本任务 */
const ScriptTask = {
  "resourceId": "",
  "properties": {
    "baseInfo": {
      "code": "",
      "name": "",
    },
    "overrideid": "",
    "scriptConf": {
      "scriptText": "",
      "resultVariable": "",
      "scriptFormat": "",
      "autoStoreVariables": "",
    },
  },
  "stencil": {
    "id": "ScriptTask",
  },
};

/* 脚本任务 */
const ServiceTask = {
  "resourceId": "",
  "properties": {
    "baseInfo": {
      "code": "",
      "name": "",
    },
    "overrideid": "",
    "serviceConf": {
      "expression": "",
      "type": "",
      "resultVariable": "",
      "failedJobRetryTimeCycleValue": "",
    },
  },
  "stencil": {
    "id": "ServiceTask",
  },
};

/* 审批任务 */
const AuditTask = {
  "resourceId": "",
  "properties": {
    "overrideid": "", // 元素编码
    "name": "",
    "documentation": "",
    "asynchronousdefinition": "false",
    "exclusivedefinition": "false",
    "executionlisteners": "",
    "multiinstance_type": "None", // 会签 None：表示无会签，Parallel：表示并行会签，Sequential：表示串行
    "multiinstance_cardinality": "",
    "multiinstance_collection": "",
    "multiinstance_variable": "",
    "multiinstance_condition": "",
    "isforcompensation": "false",
    "usertaskassignment": "", // 处理人
    "candidateGroups": [], // 用户组
    "candidateUsers": [], // 候选人
    "noticeChannel": [], // 办理人设置->通知渠道, 和candidateUsers一一对应 { code: '', name: '' }
    "relativeRelations": [], // 办理人设置->相对关系
    "description": "",
    "formId": "",
    "formkeydefinition": "",
    "formname": "",
    "formreference": "",
    "duedatedefinition": "",
    "prioritydefinition": "",
    "formproperties": "",
    "tasklisteners": "",
    "skipexpression": "",
    "categorydefinition": "AUDIT",
    "duedate": { // 已废弃
      "relativeTime": "None", // None ：未选择 ，calendar:相对于日历时间，work:相对于工作日时间
      "day": 0,
      "hour": 0,
      "minute": 0,
      "second": 0,
      "noticeusers": [],
      "noticetype": "notice",
    },
    ...baseTimeoutSetting,
    "httpcallback": {
      "isEmpty": true,  // 表示未勾选
      "parameters": [], // shape of { key: '', value:'' },
      "url": null,
    },
    "nodeAuth": {
      "cancel": false,
      "signIn": true,
      "addSignature": false,
      "delegate": false,
      "transfer": false,
      // "rollback": false,
      "rollbackToPre": false,
      "rollbackToFirst": false,
      "rollbackToAny": false,
      "takeBack": false,
      "reissue": false,
      "nextNodeHandler": false,
      "readHandle": false,
      "veto": false,
    },
  },
  "stencil": {
    "id": "UserTask",
  },
}

// 连线
const SequenceFlow = {
  "resourceId": "",
  "properties": {
    "overrideid": "",
    "name": "",
    "documentation": "",
    "conditionsequenceflow": "",
    "executionlisteners": "",
    "defaultflow": "false",
    "skipexpression": "",
  },
  "stencil": {
    "id": "SequenceFlow",
  },
}

// 排他网关
const ExclusiveGateway = {
  "resourceId": "",// 元素ID（必须）
  "properties": {
    "overrideid": "",// 同元素ID（必须）
    "name": "排他网关",// 名称（必须）
    "documentation": "",// 描述
    "asynchronousdefinition": "false",
    "exclusivedefinition": "false",
    "sequencefloworder": "",
    "executionlisteners": '',
  },
  "stencil": {// 元素类型 默认取值 （必须）
    "id": "ExclusiveGateway",
  },
}

// 并行网关
const ParallelGateway = {
  "resourceId": "",
  "properties": {
    "overrideid": "",
    "name": "并行网关",
    "documentation": "",
    "asynchronousdefinition": "false",
    "exclusivedefinition": "false",
    "sequencefloworder": "",
  },
  "stencil": {
    "id": "ParallelGateway",
  },
}
// 包含网关
const InclusiveGateway = {
  "resourceId": "",
  "properties": {
    "overrideid": "",
    "name": "包含网关",
    "documentation": "",
    "asynchronousdefinition": "false",
    "exclusivedefinition": "false",
    "sequencefloworder": "",
  },
  "stencil": {
    "id": "InclusiveGateway",
  },
}

const staticModel = {
  'Subprocess': Subprocess,
  "GroupTaskStart": GroupTaskStart,
  'GroupTaskEnd': GroupTaskEnd,
  'GroupTask': GroupTask,
  'StartNoneEvent': StartNoneEvent,
  'EndNoneEvent': EndNoneEvent,
  'UserTask': UserTask,
  'AuditTask': AuditTask,
  'ScriptTask': ScriptTask,
  'ServiceTask': ServiceTask,
  'ExclusiveGateway': ExclusiveGateway,
  'ParallelGateway': ParallelGateway,
  'InclusiveGateway': InclusiveGateway,
  'flow-polyline-round': SequenceFlow,
}

const modelJsonProperties = {
  "process_id": "", // 流程编码
  "name": "", // 流程名称
  "modelVariables": [],
  "customButtonList":[], //自定义按钮
  "copyTo": null, // 抄送人设置, null || [code: string, name: string, type: 'STA"]
  ...baseTimeoutSetting,
  "documentation": "",
  "process_author": "",
  "process_version": "",
  "process_namespace": "",
  "process_historylevel": "",
  "isexecutable": true,
  "dataproperties": "",
  "executionlisteners": "",
  "eventlisteners": "",
  "signaldefinitions": "",
  "messagedefinitions": "",
  "process_potentialstarteruser": "",
  "process_potentialstartergroup": "",
  "iseagerexecutionfetch": "false",
};

export {
  baseTimeoutSetting,
  staticModel,
  modelJsonProperties,
};
